<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"/>
    <title>订单详情</title>
    <link rel="stylesheet" type="text/css" href="/Public/assets/home/vendors/font-awesome/css/font-awesome.css"/>
    <link rel="stylesheet" type="text/css" href="/Public/assets/home/assets/css/common.css"/>
</head>
<body>

<ul class="menu">
    <li class="on"><a class="current" href="<?php echo U('orders',array('status'=>'all'));?>">全部</a></li>
    <li><a href="<?php echo U('orders',array('status'=>'1'));?>">待付款</a></li>
    <li><a href="<?php echo U('orders',array('status'=>'2'));?>">待发货</a></li>
    <li><a href="<?php echo U('orders',array('status'=>'3'));?>">已发货</a></li>
    <li><a href="<?php echo U('orders',array('status'=>'4'));?>">已完成</a></li>
</ul>

<?php if(is_array($all_orders)): $i = 0; $__LIST__ = $all_orders;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$order): $mod = ($i % 2 );++$i;?><div class="order">
        <h2>订单号：<?php echo ($order["order_no"]); ?></h2>
        <?php if($order['status'] == 1){ ?>
        <h4 class="payment"><img src="/Public/assets/home/assets/images/bg04.png" alt="待付款"></h4>
        <?php }elseif($order['status'] == 2){ ?>
        <h4 class="deliver"><img src="/Public/assets/home/assets/images/bg05.png" alt="待发货"></h4>
        <?php }elseif($order['status'] == 3){ ?>
        <h4 class="send"><img src="/Public/assets/home/assets/images/bg03.png" alt="已发货"></h4>
        <?php }else{ ?>
        <h4 class="finish"><img src="/Public/assets/home/assets/images/bg02.png" alt="已完成"></h4>
        <?php } ?>

        <?php if(is_array($order["order_product"])): $i = 0; $__LIST__ = $order["order_product"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$product): $mod = ($i % 2 );++$i;?><dl>
                <dt><img class="img-responsive" src="<?php echo ($product["product"]["thumb"]); ?>" alt="产品图片"></dt>
                <dd><?php echo ($product["product"]["name"]); ?></dd>
                <dd><span>x <?php echo ($product["number"]); ?></span>¥ <?php echo ($product["product"]["price"]); ?>元</dd>
            </dl><?php endforeach; endif; else: echo "" ;endif; ?>

        <p>总价：<em>¥ <?php echo ($order["total_price"]); ?>元</em>

            <?php if(in_array(($order["status"]), explode(',',"1"))): ?><i class="cancel" data-id="<?php echo ($oder["id"]); ?>" data-status="<?php echo ($order["status"]); ?>">取消订单</i><?php endif; ?>
        </p>
    </div><?php endforeach; endif; else: echo "" ;endif; ?>


<script type="text/javascript" src="/Public/assets/home/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="/Public/vendor/sticky/jquery.sticky.js"></script>
<script type="text/javascript" src="/Public/assets/home/assets/js/order.js"></script>
<script type="text/javascript">
    $(function () {

        // jQuery(function ($) {
        //     $(".menu").sticky({"topSpacing": 0, "responsiveWidth": true});
        //
        //     $('.more').click(function () {
        //         if ($(this).hasClass('success')) {
        //             $(this).removeClass('success');
        //             return false;
        //         }
        //         else {
        //             $(this).addClass('success');
        //         }
        //     });
        // });

        //取消订单
        $('.cancel').click(function () {
            if (confirm('确定要取消此订单么？')) {
                var id = $(this).attr('data-id');
                var status = $(this).attr('data-status');
                $.post("<?php echo U('cancel_order');?>", {
                    id: id,
                    status: status
                }, function () {
                    window.location.reload();
                })
            }
        });
    })
</script>
</body>
</html>